//
// Created by v on 19-7-4.
//

#ifndef CUTEDEVICE_C600_CMBASEPROCESS_H
#define CUTEDEVICE_C600_CMBASEPROCESS_H

#include "utils/cm_utils.h"
#include <iostream>

class CMBaseProcess
{
  public:
    CMBaseProcess(const char *sername);

  protected:
    enum
    {
        STATUS_WAIT_NEXT = 10000,
    };

    int waitNext(int status, unsigned int inter);

    int statusChanged(int status);

    int run_general();

    // You can implement this function, them some function will run in wait next
    // status But in this function, you must not change status
    virtual int run_in_wait() { return 0; }

  protected:
    int m_status;

  private:
    int                m_lastStatus;
    unsigned int       m_interval;
    unsigned long long m_lastTime;
    int                m_nextStatus;

    std::string m_serverName;
};

#endif // CUTEDEVICE_C600_CMBASEPROCESS_H
